<?php
    $registry   = Zend_Registry::getInstance();
    $constants = $registry->constants;
    $this->headLink()->appendStylesheet($this->baseUrl().'/static/css/main.css');
    $this->headLink()->appendStylesheet($this->baseUrl().'/static/css/place.css');
    $this->headScript()->appendFile("/static/js/jquery.js");
    $this->headScript()->appendFile("/static/js/jquery-ui-1.10.3.custom.js");
    $this->headScript()->appendFile("/static/js/jquery-ui-1.10.3.custom.min.js");
    $this->headScript()->appendFile("/static/js/jquery-ui-1.10.3.custom.min.js");
?>
<html>
    <head>
        <?php 
            echo $this->headLink();
            echo $this->headScript();
            ?>
        <meta charset="utf-8">
        <title>Place Detail</title>
        <link rel="shortcut icon" href="/static/images/favicon.png">
        
        
    </head>
    <body>
        <div class="wrapper">
            <div class="header">
                <div class="topbar-center">
                    <span style="color:#DF5A49;font-weight: bold">PLACE</span>
                    <span style="color:#000">DETAIL</span>
                </div>
                <div class="login-logout">
                    <span><?php echo "Xin chào ".$this->userName?></span> | <span><a href="/place/index/logout">LogOut</a></span>

                </div>
            </div>
            <div class="content">
                <div class="menu-left">
                    <ul>
                    <?php foreach($this->userFeature as $key=>$value){?>
                        <li><a href="<?php echo $value->feature_url?>"><?php echo $value->feature_name;?></a></li>
                    <?php }?>
                    </ul>
                </div>
                <div class="deal-content1">
                    <div class="content1-title" >
                    </div>
                    <div class="alert-title" id="alert"></div>
                        <div class="content1-group-input-left">
                             <input type="hidden" id="place_id" name="place_id" value="<?php echo $this->place->place_id;?>" style="text-decoration: none" />
                             <input type="hidden" value="<?php echo $this->place->sale_user_id;?>" maxlength="255" type="text" id="user_id" name="user_id"  placeholder="user_id" class="input-field-right-lager" />
                             <div class="input-field-left">Sale User</div>
                             <div class="input-field-right-lager"><?php echo $this->saleUser->login_name."-".$this->saleUser->full_name; ?></div>
                             <div class="input-field-left">Tên </div>
                             <div class="input-field-right-lager"><?php echo $this->place->name; ?></div>
                             <div class="input-field-left">Địa chỉ</div>
                             <div class="input-field-right-lager"><?php echo $this->place->address; ?></div>
                             <div class="input-field-left">Điện thoại</div>
                             <div class="input-field-right-lager"><?php echo $this->place->phone; ?></div>
                             <div class="input-field-left">Email</div>
                             <div class="input-field-right-lager"><?php echo $this->place->mail; ?></div>
                             <div class="input-field-left">Website</div>
                             <div class="input-field-right-lager"><?php echo $this->place->website; ?></div>
                             <div style="width:100%;display:block; float: left">
                                <div class="input-field-left">Mô tả</div>
                                <textarea class="input-field-right-area2" disabled="true"  name="description" ><?php echo $this->place->description;?></textarea>
                             </div>
                             <div class="input-field-left">Sản phẩm, dịch vụ</div>
                             <textarea class="input-field-right-area2" disabled="true" ><?php echo $this->place->product_service; ?></textarea>
                             <div style="width:100%;display:block; float: left">
                                <div class="input-field-left">Tag</div>
                                <textarea class="input-field-right-area2" maxlength="500" disabled="true"><?php echo $this->place->tag;?></textarea>
                             </div>
                         </div>
                        
                         <div class="content1-group-input-right">
                             <div id="map_canvas" class="map-canvas">
                             </div>
                         </div>
                    
                    <div class="button-add">
                        <button class="button-test" onclick="approveAndNext('/place/approve-place/approve-and-next')">
                            Approve And Next
                        </button>
                        <button class="button-test" onclick="rejectAndNext('/place/approve-place/reject-and-next')">
                            Reject And Next
                        </button>
                        <button class="button-test" onclick="history.back();">
                            Back
                        </button>
                    </div>
                </div>
            </div>
            
        </div>

    </body>
</html>

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>

    function approveAndNext(url){
        place_id = $.trim($("#place_id").val());
        $.get(url, {
                'place_id' : place_id
            }, function(responseData) {
            if(responseData == '<?php echo $constants->ERROR_STRING;?>'){
                $('#alert').html(responseData);
            }else{
                next_place_id = responseData;
                if(next_place_id == place_id){
                    window.location.replace("/place/approve-place/index");
                }else{
                    $('#alert').html(responseData);
                    window.location.replace("/place/approve-place/place-detail?place_id="+next_place_id);    
                }
                
            }
            
        });
    }
    
    function rejectAndNext(url){
        place_id = $.trim($("#place_id").val());
        $.get(url, {
                'place_id' : place_id
            }, function(responseData) {
            if(responseData == '<?php echo $constants->ERROR_STRING;?>'){
                $('#alert').html(responseData);
            }else{
                next_place_id = responseData;
                if(next_place_id == place_id){
                    window.location.replace("/place/approve-place/index");
                }else{
                    $('#alert').html(responseData);
                    window.location.replace("/place/approve-place/place-detail?place_id="+next_place_id);    
                }
            }
            
        });
    }
    
    function approveMultiPlace(url){
        place_id = $.trim($("#place_id").val());
        var placeList = place_id;
        $.get(url, {
            'place_list' : placeList
        }, function(responseData) {
            $('#alert').html(responseData);
            window.location.replace("/place/approve-place/index");
        });
    }
    
    function rejectMultiPlace(url){
        request_page = $.trim($("#pagging-seach").val());
        place_id = $.trim($("#place_id").val());
        var placeList = place_id;
        $.get(url, {
            'place_list' : placeList
        }, function(responseData) {
            $('#alert').html(responseData);
            window.location.replace("/place/approve-place/index");
        });
    }


    function initialize() {
        var map_canvas = document.getElementById('map_canvas');
        var myLatlng = new google.maps.LatLng(<?php echo $this->place->latitude;?>, <?php echo $this->place->longitude;?>);
        var map_options = {
          center: myLatlng,
          zoom: 16,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        
        var map = new google.maps.Map(map_canvas, map_options);
        
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: 'Hello World!'
        });
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    
   
</script>